﻿@{
    ViewBag.Title = "文章列表";
}

<script src="~/Script/laypage/laypage.js"></script>

<form method="post" action="/article/index" id="form1">
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
        <a href="/Home/center" class="home"><i></i><span>首页</span></a>
        <i class="arrow"></i>
        <span>角色管理</span>
    </div>
    <!--/导航栏-->
    <!--工具栏-->
    <div id="floatHead" class="toolbar-wrap" style="height: 52px;">
        <div class="toolbar" style="width: 1156px;">
            <div class="box-wrap">
                <a class="menu-btn"></a>
                <div class="l-list">
                    <ul class="icon-list">
                        <li><a class="add" href="/managerrole/edit"><i></i><span>新增</span></a></li>
                        <li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li>
                        <li><a onclick="return ExePostBack('DelRole', '本操作会删除角色及相关权限，是否继续？');" id="DelRole" class="del" href="/ManagerRole/Del"><i></i><span>删除</span></a></li>
                    </ul>
                </div>
                <div class="r-list">
                    <input name="M_Name" type="text" id="M_Name" class="keyword" value="@(ViewBag.P_Name as string)">
                    <a id="lbtnSearch" class="btn-search" href="javascript:void(0);" onclick="return Search(this)">查询</a>
                </div>
            </div>
        </div>
    </div>
    <!--/工具栏-->
    <!--列表-->
    <div class="table-container">
        <table style="width:100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
            <thead>
                <tr>
                    <td>文章Id</td>
                    <td>文章标题</td>
                    <td>所属专栏</td>
                    <td>阅读数</td>
                    <td>评论数</td>
                    <td>发布时间</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody id="tbody1"></tbody>
        </table>

    </div>
    <div class="common_page clearfix">
        <div class="fy_right fr page" id="page1">

        </div>
    </div>
    <!--/分页列表-->
    <script type="text/javascript">
        $(function () {
            bindFocusMyproject();
        });
        function bindFocusMyproject(curr) {
            var str = "";
            $("#tbody1").empty();
            var data = {
                Name: $("#M_Name").val(),
                CurrentIndex: curr || 1,
                PageSize: 10
            };
            $.getJSON('@Url.Action("Article", "List")', data, function (res) {

                //此处仅仅是为了演示变化的内容
                if (res.Items.length > 0) {
                    for (var i = 0; i < res.Items.length; i++) {
                        str += "<tr " + (i % 2 == 0 ? 'class=\'odd_bg\'' : '') + ">"
                        str += "<td>" + res.Items[i].Id + "</td>"
                        str += "<td>" + res.Items[i].Title + "</td>"
                        str += "<td>" + res.Items[i].CategoryName + "</td>"
                        str += "<td>" + res.Items[i].ViewCount + "</td>"
                        str += "<td>" + res.Items[i].CommentCount + "</td>"
                        str += "<td>" + res.Items[i].CreateTime + "</td>"
                        str += "<td>" + res.Items[i].Status + "</td>"
                        str += "<td><a>下架</a>|<a>删除</a></td>"
                        + "</tr>";
                    }
                    $("#tbody1").append(str);
                    $("#page1").show();
                    //显示分页
                    laypage({
                        cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: res.Count, //通过后台拿到的总页数
                        curr: curr || 1, //当前页
                        skip: true,
                        jump: function (obj, first) { //触发分页后的回调
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                                bindFocusMyproject(obj.curr);
                            }
                        }
                    });
                } else {
                    $("#tbody1").append("<tr><td colspan='8'>未查询到数据</td></tr>");
                    $("#page1").hide();
                }
            });
        }

    </script>
</form>


